import { createAxios } from '@/utils/http/axios';

enum Api {
  cfgLog = '/tbuser/deviceControl/logCfg',
  sendImageValue = '/tbuser/deviceControl/sendSetParamBySn',
  setPreActiveStatus = '/tbuser/deviceControl/setPreActiveStatus',
  powerControl = '/tbuser/deviceControl/powerControl',
}

export function cfgLogApi(data: any) {
  return createAxios({
    requestOptions: {
      apiUrl: '/hc-api',
    },
  }).post(
    {
      url: Api.cfgLog,
      data: data,
    },
    {
      retryRequest: {
        isOpenRetry: true,
        count: 5,
        waitTime: 1000,
      },
    },
  );
}

export function sendImageValueApi(data: { sn: string; paramMap: any }) {
  return createAxios({
    requestOptions: {
      apiUrl: '/hc-api',
    },
  }).post({
    url: Api.sendImageValue,
    data: data,
  });
}

export function setPreActiveStatusApi(data: {
  sn: string;
  status: number;
  env: string;
  region: string;
}) {
  return createAxios({
    requestOptions: {
      apiUrl: '/hc-api',
    },
  }).post({
    url: Api.setPreActiveStatus,
    data: data,
  });
}

export function powerControlApi(data: { sn: string; model: number }) {
  return createAxios({
    requestOptions: {
      apiUrl: '/hc-api',
    },
  }).post({
    url: Api.powerControl,
    data: data,
  });
}
